home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 33 < prev    next >
Text File  |  1996-08-06  |  2KB  |  60 lines

  1. Path: afep.yorku.ca!ken
  2. From: ken@yorku.ca (Kenneth Kafieh)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Faster FILE subroutines in standard C?
  5. Date: 5 Jan 1996 16:33:23 GMT
  6. Organization: York University
  7. Message-ID: <4cjjsj$3h5@sunburst.ccs.yorku.ca>
  8. References: <4cfm7c$dot@sunburst.ccs.yorku.ca> <4cj473$n0m@gabi.gabi-soft.fr>
  9. NNTP-Posting-Host: afep.yorku.ca
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. J. Kanze (kanze@gabi-soft.fr) wrote:
  13. : Kenneth Kafieh (ken@yorku.ca) wrote:
  14.  
  15. : |> I found that I was able to get 3-4 time faster performance by using good 
  16. : |> old ANSI C file accessing routines (like  fgets, fseek, ftell, ...etc.)
  17. : |> instead of C++ streams (like ifstream::getline, fstream::seekg, ...etc.)
  18. : |> I wrote the program originally in C++ (a simple little phonebook for my
  19. : |> own use) and it took about 9 seconds to scan a 100Kb file for a 3 byte
  20. : |> string!!!  Fed up, I rewrote it in C and voila! Now it takes 2 secs!
  21. : |> I'm using Borland C++ v2.0.
  22.  
  23. : |> Does that sound right?  Maybe my code was inefficiently written?
  24. : |> I know C++ is generally slower than C but I didn't think that 
  25. : |> file stuff would be too.   What did I do wrong? Am I missing
  26. : |> something.  Maybe I'll post the code too, later. Has anyone
  27. : |> else noticed this too?
  28.  
  29. : This depends on the implementation.  With g++ 2.7.2 (libg++ 2.7.1), for
  30. : example, formatted output with iostream is more than twice as fast as
  31. : using fprintf.
  32.  
  33. : |> Come to think of it, the coding in
  34. : |> C was cleaner looking, too.  
  35.  
  36. : And more error prone (putting on my abestos suit).
  37.  
  38. : More to the point: I'm currently reading this in comp.std.c, so I would
  39. : guess that iostream is irrelevant, off-topic, and doesn't necessarily
  40. : interest all of the readers.  In C, you don't have the choice.  (The
  41. : same article was posted to comp.lang.c++.moderated, where it is
  42. : relevant.  I would suggest that anyone wishing to follow up to this
  43. : posting do so there.)
  44. : -- 
  45. : James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  46. : GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  47. : Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  48. :               -- A la recherche d'une activitΘ dans une region francophone
  49.  
  50. --
  51. Sorry.  I TRIED to delete the posting afterwords but by now it's 
  52. clear that not only is there something wrong with my compiler, but 
  53. also with my news reader.
  54.  
  55.  
  56.  
  57. And So Until Next Time...
  58.  
  59.                 I'm Ken
  60.